<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/5/9 0009
  Time: 18:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%String path = request.getContextPath();%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="../../inc/header.jsp"></jsp:include>
<!-- Page Heading Section Start -->
<div class="page-heading-section section bg-parallax" data-bg-image="<%=path%>/assets/images/bg/bg-1.jpg" data-overlay="50">
    <div class="container">
        <div class="page-heading-content text-center">
            <h2 class="title">寻找你的HR</h2>
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="<%=path%>/web/index">网站首页</a></li>
            </ol>
        </div>
    </div>
</div>
<!-- Page Heading Section End -->

<!-- Recent Jobs Start -->
<div class="section section-padding">
    <div class="container">
        <!-- Job List Wrap Start -->
        <div class="job-list-wrap">

            <!-- Job List Start -->
            <c:forEach items="${pageInfo.list}" var="person">
                <a class="job-list">
                    <div class="company-logo col-auto">
                        <img src="<%=path%>/assets/images/companies/company-1.png" alt="Company Logo">
                    </div>
                    <div class="salary-type col-auto order-sm-3">
                        <div class="btns">
                            <c:if test="${person.isCompanyHr ne true}">
                                <button type="button" id="mybtn" data-id="${person.id}" data-name="renew" class="badge badge-success">恢复HR身份</button>
                            </c:if>
                            <c:if test="${person.isCompanyHr eq true}">
                                <button type="button" id="mybtn" data-id="${person.id}" data-name="cancel" class="badge badge-danger">取消HR身份</button>
                            </c:if>
                        </div>
                    </div>
                    <div class="content col">
                        <h6 class="title">${person.name}</h6>
                        <ul class="meta">
                            <li><strong class="text-primary">HR</strong></li>
                            <li><strong class="text-primary">邮箱：</strong></li>
                            <li>${person.email}</li>
                            <li><strong class="text-primary">手机号：</strong></li>
                            <li>${person.phone}</li>
                        </ul>
                    </div>
                </a>
            </c:forEach>
            <!-- Job List Start -->
            <!-- Pagination Start -->
            <ul class="pagination pagination-center mt-5">

                <li class="page-item"><a class="page-link" id="prePage" data-id="${pageInfo.pageNum-1}"><i class="fa fa-angle-left"></i></a></li>

                <c:if test="${pageInfo.pages>=5}">
                    <c:if test="${pageInfo.pageNum>=3 && pageInfo.pageNum<=pageInfo.pages-2}">
                        <c:forEach begin="${pageInfo.pageNum-2}" end="${pageInfo.pageNum+2}" var="stat">
                            <c:if test="${stat eq pageInfo.pageNum}">
                                <li class="page-item active"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                            </c:if>
                            <c:if test="${stat ne pageInfo.pageNum}">
                                <li class="page-item"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                            </c:if>
                        </c:forEach>
                    </c:if>
                    <c:if test="${pageInfo.pageNum<3}">
                        <c:forEach begin="1" end="5" var="stat">
                            <c:if test="${stat eq pageInfo.pageNum}">
                                <li class="page-item active"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                            </c:if>
                            <c:if test="${stat ne pageInfo.pageNum}">
                                <li class="page-item"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                            </c:if>
                        </c:forEach>
                    </c:if>
                    <c:if test="${pageInfo.pageNum>pageInfo.pages-2}">
                        <c:forEach begin="${pageInfo.pages-4}" end="${pageInfo.pages}" var="stat">
                            <c:if test="${stat eq pageInfo.pageNum}">
                                <li class="page-item active"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                            </c:if>
                            <c:if test="${stat ne pageInfo.pageNum}">
                                <li class="page-item"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                            </c:if>
                        </c:forEach>
                    </c:if>
                </c:if>
                <c:if test="${pageInfo.pages<5}">
                    <c:forEach begin="1" end="${pageInfo.pages}" var="stat">
                        <c:if test="${stat eq pageInfo.pageNum}">
                            <li class="page-item active"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                        </c:if>
                        <c:if test="${stat ne pageInfo.pageNum}">
                            <li class="page-item"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                        </c:if>
                    </c:forEach>
                </c:if>

                <li class="page-item"><a class="page-link" id="nextPage" data-id="${pageInfo.pageNum+1}"><i class="fa fa-angle-right"></i></a></li>

            </ul>
            <!-- Pagination End -->
        </div>
        <!-- Job List Wrap Start -->


    </div>
</div>
<!-- Recent Jobs End -->

<script type="text/javascript" src="<%=path%>/assets/js/vendor/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
    $(function () {
        $.each($("a[id^=page]"),function () {
            $(this).on("click",$(".job-list-wrap"),function () {
                var pageNum = $(this).attr("data-id");
                $.ajax({
                    url:"<%=path%>/web/company/manage/hr/hrListData",
                    type:"post",
                    data:"pageNum="+pageNum,
                    async:"false",
                    success:function (data) {
                        $(".job-list-wrap").html(data);
                    }
                });
            })
        });
        $("#prePage").on("click",$(".job-list-wrap"),function () {
            var pageNum = $("#prePage").attr("data-id");
            if(pageNum<=0){
                pageNum = 1;
            }
            $.ajax({
                url:"<%=path%>/web/company/manage/hr/hrListData",
                type:"post",
                data:"pageNum="+pageNum,
                async:"false",
                success:function (data) {
                    $(".job-list-wrap").html(data);
                }
            });
        });
        $("#nextPage").on("click",$(".job-list-wrap"),function () {
            var pageNum = $("#nextPage").attr("data-id");
            if(pageNum>${pageInfo.pages}){
                pageNum = ${pageInfo.pages};
            }
            $.ajax({
                url:"<%=path%>/web/company/manage/hr/hrListData",
                type:"post",
                data:"pageNum="+pageNum,
                async:"false",
                success:function (data) {
                    $(".job-list-wrap").html(data);
                }
            });
        });
        var button = $("button[id=mybtn]");
        $.each(button,function () {
            $(this).click(function () {
                var ts = $(this);
                var data_name = ts.attr("data-name");
                var data_id = ts.attr("data-id");
                if(data_name=='cancel'){
                    ts.attr("data-name","renew");
                    ts.html("恢复HR身份");
                    ts.attr("class","badge badge-success");
                }
                if(data_name=='renew'){
                    ts.attr("data-name","cancel");
                    ts.html("取消HR身份");
                    ts.attr("class","badge badge-danger");
                }
                //数据库enable取反
                $.ajax({
                    url:"<%=path%>/web/company/manage/hr/updateHr",
                    data:"id="+data_id
                });
            });
        });
    });
</script>
<jsp:include page="../../inc/footer.jsp"></jsp:include>

